

var LOGIN_INIT_STATE = { //登录相关信息
  isFromAuthor: false, //是否从登录授权页面返回回去的 true:是 false:否 
  userPermissions:[]
}
var INIT_STATE = { //主要的
  lock_code: '', // 锁的id
  connected: false, // 是否有链接的
  isFromChooseCabinet: false, // 是否来自选择电表柜
  cabinet_name: '', // 电表柜名称
  cabinet_id: '', // 电表柜id
  userRoleList:[],
  ticketRolist:[]
}
var FORM_INIT_STATE = { // 表单相关信息
  form: {
    key: '', // 后台要的更改字段 
    type: '', // 表单类型 1： radio  2：select
    selected: '', // 选中的
    config: { // 其他配置信息
      // type:3
    },
  },
}

 
export default {
	login(state = LOGIN_INIT_STATE, action) {
		switch (action.type) {
			case 'SET_IS_FROM_AUTHOR':
				return { ...state,
          isFromAuthor: action.isFromAuthor,
				}
        break;
      
			default:
				return state
		}
	},
  formInfor(state = FORM_INIT_STATE, action) {
    switch (action.type) {
      case 'SET_FROM':
        return {
          ...state,
          form: action.form
        }
        break;
      default:
        return state
    }
  },
  main(state = INIT_STATE, action) {
		switch (action.type) {
      case 'SET_USER_ROLE':
        return { ...state,
          userRoleList:action.userRoleList
        }
        break;
      case 'SET_TICKET_ROLE':
        return { ...state,
          ticketRolist:action.ticketRolist
        }
        break;
      case 'SET_LOCK_DATA':
				return { ...state,
          lock_data: action.lock_data
				}
        break;
			case 'SET_LOCK_CODE':
				return { ...state,
          lock_code: action.lock_code
				}
        break;
      case 'UPDATE_CONNECTED':
        return {
          ...state,
          connected: action.connected
        }
        break;
      case 'UPDATE_IS_FROM_CHOOSECABINET':
        return {
          ...state,
          isFromChooseCabinet: action.isFromChooseCabinet
        }
        break;
      case 'UPDATE_CABINET_NAME':
        return {
          ...state,
          cabinet_name: action.cabinet_name
        }
        break;
      case 'UPDATE_CABINET_ID':
        return {
          ...state,
          cabinet_id: action.cabinet_id
        }
        break;
			default:
				return state
		}
	}
}
